let jwt = require('jsonwebtoken');
const { miyao, expires } = require('../config/config');
// 加密token
exports.settoken = info => {
    return jwt.sign(info, miyao, { expiresIn: expires })
}
// 解密token    
exports.parseToken = token => {
    return new Promise(resolve => {
        jwt.verify(token, miyao, (err, data) => {
            if (err) {
                resolve({ code: 0, message: '解析失败' })
                return
            }
            // 代码能执行到这里 说明解析成功了
            resolve({ code: 1, message: '解析成功了', info: data })
        })
    })
}
